///**
// * @author Xue ShuWen
// * @date 2022/11/20 16:48
// */
//import org.apache.spark.sql.SparkSession
//
//object Mysql {
//
//  import java.sql.{Connection, DriverManager, ResultSet}
//
//  def main(args: Array[String]): Unit = {
//
//
//    // Change to Your Database Config
//    val conn_str = "jdbc:mysql://localhost:3306/stuInfo?user=root&password=root"
//    // Load the driver
//    classOf[com.mysql.cj.jdbc.Driver]
//    // Setup the connection
//    val conn = DriverManager.getConnection(conn_str)
//
//    // Configure to be Read Only
//    val statement = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)
//
//    // Execute Query
//    val rs = statement.executeQuery("select classNo,count(gender) ,sum(case when gender=1 then 1 else 0 end ) 男,sum(case when gender='0' then 1 else 0 end ) 女 from studentInfo group by classNo")
//
//    // Iterate Over ResultSet
//
//    while (rs.next()) {
//      //打印到控制台
//      println(rs.getString("classNo") + "," + rs.getString("count(gender)") + "," + rs.getString("男") + "," + rs.getString("女"))
//    }
//    rs.close()
//    statement.close()
//    conn.close()
//  }
//
//}